#@front_layout()
	
#define css()
	
#end

#define page()
<div class="page">
	<header class="bar bar-nav">
		 <a class="icon icon-me pull-left open-panel"></a>
	    <a class="icon icon-refresh pull-right"></a>
	    <h1 class="title">英文选意</h1>
	</header>
	<div class="content">
		<div class="content-padded">
			#for(word : qasList)
			<div class="word-item" #if(word.show == "false") style="display: none" #end>
				<div class="content-block-title" style="text-transform: none;">#(word.word)</div>
				<div class="list-block">
					<ul>
						#for(answer : word.answers)
						<li>
							<label class="label-checkbox item-content">
				   				<input type="radio" name="word[#(word.word)]" class="checkItem" value="#(answer.value)">
				   				<div class="item-media"><i class="icon icon-form-checkbox"></i></div>
				    			<div class="item-inner">
									<div class="item-title-row">
										<div class="item-title">#(answer.text)</div>
									</div>
								</div>
							</label>
						</li>
						#end
					</ul>
				</div>
				<div class="content-block-title" style="text-transform: none;">当前第#(for.count)/#(for.size)个</div>
			</div>
			#end
		</div>
	</div>
</div>
#end

#define js()
<script>

var errorWords = [];

$(function() {
	$(".checkItem").change(function() {
		var v = $(this).attr("name").replace("word[", "").replace("]", "");
		if($(this).val() == v) {
// 			$(this).parent().parent().parent().parent().parent().hide();
			$(this).parents(".word-item").hide();
			$(this).parents(".word-item").next().show();
		} else {
			var existFlag = false;
			var existIndex = 0;
			for(var i = 0; i < errorWords.length; i++) {
				if(errorWords[i].word == v) {
					existFlag = true;
					existIndex = i;
					break;
				}
			}
			if(existFlag) {
				errorWords[existIndex].errorCount ++;
			} else {
				var obj = {};
				obj.word = v;
				obj.errorType = 'E2C';
				obj.errorCount = 1;
				errorWords.push(obj);
			}
			
			
			NB.alert("你选错了");
			return;
		}
		if($(this).parents(".word-item").next().length == 0) {
			NB.alert("没有了", function() {
				$.post(ctx + "/insertErrorWord", {errorWords: JSON.stringify(errorWords)}, function(data) {
					window.location.href = ctx + "/checkView";
				});
			});
		}
	});
});
</script>
#end